<template>
  <el-container>
    <el-aside width="500px">
      <el-form size="mini" model="domains" label-width="100px">
        <el-form-item
          v-for="(domain, index) in getDomains"
          :label="domain.label"
          :key="index"
        >
          <el-input
            type="textarea"
            :rows="1"
            placeholder="请输入内容"
            v-model="domain.value"
          ></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="submitForm('domains')"
            >提交</el-button
          >
        </el-form-item>
      </el-form>
    </el-aside>
    <el-aside width="500px">
      <el-form size="mini">
        <el-form-item>
          <el-input type="textarea" autosize v-model="result"></el-input>
        </el-form-item>
      </el-form>
    </el-aside>
  </el-container>
</template>
<script>
import { gmExecReq } from "../api/req";
export default {
  data() {
    let domains = [];
    return {
      domains: domains,
      result: "",
    };
  },
  methods: {
    submitForm() {
      this.result = "";
      let rObj = {};
      for (let domain of this.domains) {
        rObj[domain.label] = domain.value;
      }
      rObj.requestServer = this.$store.state.navConActiveIndex;
      gmExecReq(rObj).then((res) => {
        this.result = JSON.stringify(res, null, 2);
      });
    },
  },
  created() {},
  computed: {
    getDomains() {
      this.domains = this.$store.state.gmContent;
      return this.domains;
    },
  },
};
</script>